package com.linzm.proxy;

/**
 * @Author zimingl
 * @Date 2023/8/21 23:22
 * @Description: TODO
 */
interface Subject {

}

// 原始类
class RealSubject implements Subject {
    public void doSomething() {
        System.out.println("RealSubject 执行了某些操作。");
    }
}

// 代理类
class ProxySubject implements Subject {
    private RealSubject realSubject;

    public ProxySubject(RealSubject realSubject) {
        this.realSubject = realSubject;
    }

    public void doSomething() {
        System.out.println("代理类执行前的逻辑。");
        realSubject.doSomething();
        System.out.println("代理类执行后的逻辑。");
    }
}

public class StaticProxy {
    // 使用代理类
    public static void main(String[] args) {
        RealSubject realSubject = new RealSubject();
        ProxySubject proxySubject = new ProxySubject(realSubject);
        proxySubject.doSomething();
    }
}
